package order

import (
	"context"
	"fmt"
)

type Repository interface { //Order操作接口
	Create(ctx context.Context, o *Order) (*Order, error) //返回order类型，为了方便获知创建的结果
	Get(ctx context.Context, id, customerID string) (*Order, error)
	Update(
		ctx context.Context,
		o *Order,
		updateFn func(context.Context, *Order) (*Order, error),
	) error
}

type NotFoundError struct { //获取订单失败
	OrderID string
}

func (e NotFoundError) Error() string { //转成Error---实现Error接口即可
	return fmt.Sprintf(" order %s not found!", e.OrderID)
}
